import pandas as pd
import requests
import urllib.parse
import time
from tqdm import tqdm

# 输入和输出的Excel文件路径
input_file_path = 'detail.xlsx'    # 请替换为你的输入Excel文件路径

# 读取Excel文件
try:
    df = pd.read_excel(input_file_path)
    # df = pd.DataFrame(data)

    # 生成JavaScript数组
    js_array = "const shops = [\n"
    for index, row in df.iterrows():
        js_array += f"    {{name: '{row['店名']}', lng: {row['经度']}, lat: {row['纬度']}, cost: '{row['人均消费']}', address:'{row['地址']}'  }},\n"
    js_array += "];"

    print(js_array)

    # 将拼接的内容保存到 content.js 文件中
    with open("content.js", "w", encoding="utf-8") as file:
        file.write(js_array)
except Exception as e:
    print(f"读取Excel文件时出错: {e}")
    exit(1)